package com.gjy.pulsar.function;


import org.apache.pulsar.functions.api.Context;
import org.apache.pulsar.functions.api.Function;
import org.slf4j.Logger;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-08-26 12:19:51
 */
public class UpperCaseFunction implements Function<String, String> {

    @Override
    public String process(String input, Context context) throws Exception {
        Logger logger = context.getLogger();
        if (input == null || input.isEmpty()) {
            logger.error("received empty message, skipping...");
            return "";
        }
        String upperCase = input.toUpperCase();
        logger.info("convert message: [input: {}]->[output: {}]", input, upperCase);
        return upperCase;
    }
}
